package main

import (
	"Ljohn/netTest/grpcTest/pb"
	"context"
	"fmt"
	"google.golang.org/grpc"
)

func main() {
	conn, err := grpc.Dial("127.0.0.1:1011", grpc.WithInsecure())
	if err != nil {
		fmt.Println("连接失败：", err)
	}
	// 函数结束时关闭连接
	defer conn.Close()

	cli := pb.NewTestClient(conn)
	t := pb.Empty{}
	res, err := cli.Echo(context.Background(), &t)
	if err != nil {
		fmt.Println("通信失败", err)
		return
	}
	fmt.Println(res.Ss)
	in := pb.ContentX{}
	in.Hi = "L"
	ctx := context.Background()
	ctx = context.WithValue(ctx, "k", "123")
	fmt.Println("------------->", ctx)
	r, err := cli.EchoContent(ctx, &in)
	if err != nil {
		fmt.Println("通信失败", err)
		return
	}
	fmt.Println(r)
}
